﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Gao.Poker.Domain;
using Gao.Poker.ViewModel;

namespace Gao.Poker.App.Win
{
    /// <summary>
    /// Interaction logic for MemberManageWin.xaml
    /// </summary>
    public partial class MemberManageWin : Window
    {
        private MemberMangeViewModel _viewModel;

        
        public MemberManageWin()
        {
            InitializeComponent();
            _viewModel = new MemberMangeViewModel();
            _viewModel.Message = OnMessage;
            DataContext = _viewModel;

            btnSearch.Click += Search_Click;

        }

        private void Search_Click(object sender, RoutedEventArgs e)
        {
            _viewModel.OnPropertyChanged("Members");
        }

        private void OnMessage(string obj)
        {
            MessageBox.Show(obj, "提示消息");
        }

        private void Recharge_Click(object sender, RoutedEventArgs e)
        {
            Member member = dgMembers.SelectedItem as Member;
            if(member == null)
            {
                OnMessage("当前需要充值的会员不能为空！");
                return;
            }

            RechargeWin win = new RechargeWin();
            win.Member = member;
            win.ViewModel = _viewModel;
            win.Show();
        }
    }
}
